{{define "title"}}{{.article.Title}} {{end}}
{{define "seo"}}<meta name="keywords" content="{{.setting.SeoKeywords}}">
<meta name="description" content="{{substring .article.Txt 200 ""}}">{{end}}
{{define "content"}}

{{include "common/suspend.html" .}}

<div class="row">
	<div class="col-md-9 col-sm-6">
		<div class="sep20"></div>
		<ol class="breadcrumb">
			<li><a href="/">首页</a></li>
			<li><a href="/articles">文章</a></li>
		</ol>
		<div class="page">
			<div class="box_white" style="overflow: visible;">
				<div class="title">
					{{if .article.IsSelf}}
					<div class="pull-right">
						{{if .article.GCTT}}
							<a href="/gctt/{{.article_gctt.Translator}}" title="{{.article_gctt.Translator}}">
								<img src="{{.article_gctt.Avatar}}" alt="{{.article_gctt.Translator}}" width="62px" height="62px">
							</a>
						{{else}}
							<a href="/user/{{.article.User.Username}}" title="{{.article.User.Username}}">
								<img src="{{gravatar .article.User.Avatar .article.User.Email 62 .is_https}}" alt="{{if .article.User.Name}}{{.article.User.Name}}{{else}}{{.article.User.Username}}{{end}}" width="62px" height="62px">
									{{if .article.User.IsVip}}
										<span class="article-prosign"> &#9733 VIP</span>
									{{end}}
							</a>
						{{end}}
					</div>
					{{end}}
					<h1 id="title" data-id="{{.article.Id}}">
						{{.article.Title}}
					</h1>
					<small class="c9">
					{{if .article.GCTT}}
						<a href="/gctt/{{.article_gctt.Translator}}">{{.article_gctt.Translator}}</a>
					{{else}}
						{{if .article.IsSelf}}
						<a href="/user/{{.article.User.Username}}">{{.article.User.Username}}</a>
						{{else}}
						<span>{{.article.AuthorTxt}}</span>
						{{end}}
					{{end}}
						 · <span title="{{.article.Ctime}}" class="timeago"></span> · {{.article.Viewnum}} 次点击 ·
						<span class="read-time"></span> ·
						<span class="timeago" title="{{.cur_time}}"></span> 开始浏览 &nbsp; &nbsp;
					{{if canEdit .me .article}}
						{{if .article.Markdown}}
						<a class="op" href="/articles/modify?id={{.article.Id}}" title="编辑">编辑</a>
						{{else}}
						<a id="edit" class="op" href="javascript:" title="编辑">编辑</a>
						{{end}}
					{{end}}
					</small>
				</div>
				{{if gt (distanceDay .article.Ctime) 100 }}
				<div class="outdated">这是一个创建于 <span title="{{.article.Ctime}}" class="timeago"></span> 的文章，其中的信息可能已经有所发展或是发生改变。</div>
				{{end}}
				<div class="cell">
					{{if .article.Markdown}}
					<div class="content markdown-body">{{.article.Content}}</div>

					{{if .article.GCTT}}
					<hr>
					<p>via: <a href="{{.article_gctt.URL}}" title="" target="_blank">{{.article_gctt.URL}}</a></p>
					<p>
						作者：<a href="{{.article_gctt.AuthorURL}}" class="ext" rel="external nofollow" target="_blank">{{.article_gctt.Author}}</a>&nbsp;
						译者：<a href="https://github.com/{{.article_gctt.Translator}}" class="ext" rel="external nofollow" target="_blank">{{.article_gctt.Translator}}</a>&nbsp;
						校对：{{range .article_gctt.Checkers}}<a href="https://github.com/{{.}}" class="ext" rel="external nofollow" target="_blank">{{.}}</a> {{end}}
					</p>
					<p>本文由 <a href="https://github.com/studygolang/GCTT" class="ext" rel="external nofollow" target="_blank">GCTT</a> 原创编译，<a href="/articles/{{.article.Id}}">{{.setting.Name}}</a> 荣誉推出</p>

					<div class="alert" role="alert" style="background-color:rgba(24,241,24,0.1);">
						<p class="copyright" style="line-height: 1.5em;">
							<span>本文由 GCTT 原创翻译，<a href="/articles/{{.article.Id}}">{{.setting.Name}}</a> 首发。也想加入译者行列，为开源做一些自己的贡献么？欢迎加入 <a href="/gctt" target="_blank">GCTT</a>！<br>
							翻译工作和译文发表仅用于学习和交流目的，翻译工作遵照 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" target="_blank">CC-BY-NC-SA 协议规定</a>，如果我们的工作有侵犯到您的权益，请及时联系我们。</span><br>
							<span style="color:red;">欢迎遵照 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" target="_blank">CC-BY-NC-SA 协议规定</a> 转载，敬请在正文中标注并保留原文/译文链接和作者/译者等信息。</span><br>
							<span>文章仅代表作者的知识和看法，如有不同观点，请楼下排队吐槽</span>
						</p>
					</div>

					{{end}}

					{{else}}
					<div id="myeditor" class="content article-entry">
						{{noescape .article.Content}}
					</div>
					{{end}}

					{{if not .article.IsSelf}}
					<div class="row orig-info">
						<p>本文来自：<a href="/wr?u=http://{{.article.Domain}}" target="_blank" title="{{.article.Name}}">{{.article.Name}}</a></p>
						<p>感谢作者：{{noescape .article.AuthorTxt}}</p>
						<p>查看原文：<a href="/wr?u={{.article.Url}}" target="_blank" title="{{.article.Title}}">{{.article.Title}}</a></p>
					</div>
					{{end}}
				</div>

				<!-- 加群等 -->
				{{include "common/promotion.html" .}}

				<div class="content-buttons">
					<div class="pull-right c9 f11" style="line-height: 12px; padding-top: 3px; text-shadow: 0px 1px 0px #fff;">{{.article.Viewnum}} 次点击 &nbsp;{{if .article.Likenum}}∙&nbsp; {{.article.Likenum}} 赞 &nbsp; {{end}}</div>
					<a class="tb collect" href="javascript:;" title="{{if .hadcollect}}取消收藏{{else}}加入收藏{{end}}" data-objid="{{.article.Id}}" data-objtype="1" data-collect="{{.hadcollect}}">{{if .hadcollect}}取消收藏{{else}}加入收藏{{end}}</a>
					<a href="javascript:" class="tb weibo-btn">微博</a>
					<div id="content-thank">
						<a class="tb" href="javascript:;" title="{{if .likeflag}}取消赞{{else}}赞{{end}}" data-objid="{{.article.Id}}" data-objtype="1" data-flag="{{.likeflag}}">{{if .likeflag}}取消赞{{else}}赞{{end}}</a>
					</div>
				</div>
			</div>
			<!-- content END -->

			<div class="sep20"></div>
			<div class="box_white">
				<div class="cell subject">
					{{if .subjects}}<div><i class="fa fa-list"></i> 被以下专栏收入，发现更多相似内容</div>{{end}}
					<div class="item-list">
					{{range .subjects}}
						<a href="/subject/{{.Id}}" title="{{.Name}}" class="item">
							<img src="{{if .Cover}}{{imageUrl .Cover $.is_https}}{{else}}https://static.studygolang.com/logo/green-logo-1.png{{end}}" alt="{{.Name}}" width="32px">&nbsp;<span>{{.Name}}</span>
						</a>
					{{end}}
						<a class="add-collection" href="javascript:"><i class="fa fa-plus"></i> 收入我的专栏</a>
					</div>
				</div>
			</div>

			<div class="sep20"></div>
			<div class="box_white">
				<div class="cell row">
					{{if .prev}}
					<div class="col-sm-6">上一篇：<a href="/articles/{{.prev.Id}}">{{.prev.Title}}</a></div>
					{{end}}
					{{if .next}}
					<div class="col-sm-6 right">下一篇：<a href="/articles/{{.next.Id}}">{{.next.Title}}</a></div>
					{{end}}
				</div>
			</div>

			<div class="sep20"></div>

			<!-- 评论列表 -->
			<div id="replies" class="box_white">
				<div class="cell">
					<div class="pull-right" style="margin: -3px -5px 0px 0px;">
					{{if .article.Tags}}
						{{$tags := explode .article.Tags ","}}
						{{range $tags}}
						<a href="/tag/{{.}}" class="tag"><li class="fa fa-tag"></li> {{.}}</a>
						{{end}}
					{{end}}
					</div>
					{{if .article.CloseReply}}
						<span class="c9">作者关闭了回复功能</span>
					{{else}}
						<span class="c9"><span class="cmtnum">{{.article.Cmtnum}}</span> 回复 {{if .article.Cmtnum}}&nbsp;<strong class="snow">|</strong> &nbsp;直到 {{.article.Lastreplytime}}{{end}}</span>
					{{end}}
				</div>
				{{include "common/comment-page.html" .}}
				<div class="comment-list cell" data-objid="{{.article.Id}}" data-objtype="1" {{if .me.Uid}}data-username="{{.me.Username}}" data-uid="{{.me.Uid}}" data-avatar="{{gravatar .me.Avatar .me.Email 48 .is_https}}"{{end}}>
					<div class="words hide"><div class="text-center">暂无回复</div></div>
				</div>
				{{include "common/comment-page.html" .}}
			</div>

			{{if not .article.CloseReply}}
			<!-- 评论框 -->
			{{template "comment" .}}
			{{end}}

			{{include "common/view_stat.html" .}}

		</div>
	</div>
	<div class="col-md-3 col-sm-6">
		<div class="sep20"></div>
		{{include "common/my_info.html" .}}

		{{if .pos_ad.right1}}
		<div class="box_white sidebar" id="ad-right1">
			{{if eq .pos_ad.right1.AdType 0}}
				{{noescape .pos_ad.right1.Code}}
			{{end}}
		</div>
		{{end}}

		{{include "sidebar/view_rank.html" (parseJSON `{"rank_title":"今日阅读排行","objtype":1,"limit":10,"rank_type":"today"}`)}}

		{{if .pos_ad.right2}}
		<div class="box_white sidebar" id="ad-right2">
			{{if eq .pos_ad.right2.AdType 0}}
				{{noescape .pos_ad.right2.Code}}
			{{end}}
		</div>
		{{end}}

		{{include "sidebar/view_rank.html" (parseJSON `{"rank_title":"一周阅读排行","objtype":1,"limit":10,"rank_type":"week"}`)}}

		{{include "sidebar/concern.html" .}}

	</div>
</div>

{{include "common/modal.html" .}}

{{if not .article.Markdown}}
<template id="content_tpl">
{{noescape .article.Content}}
</template>
{{end}}

{{end}}

{{define "css"}}
<style>
pre .line { margin: auto; line-height: 20px; border-bottom: none; }
.image-package .image-container-fill { padding-bottom: 0 !important; }
</style>

{{if .article.Css}}
<link href="{{.article.Css}}" media="screen" rel="stylesheet" type="text/css">
{{end}}

{{include "cssjs/prism.css.html" .}}

{{end}}

{{define "js"}}

<script type="text/javascript" src="{{.static_domain}}/static/dist/js/articles.min.js"></script>

<script type="text/javascript">
// 需要加载的侧边栏
SG.SIDE_BARS = [
	"/rank/view",
];

var keyprefix = 'article';
var objid = {{.article.Id}};

$(function(){
	{{if .article.Markdown}}
	new SG.Articles().parseContent($('.page .content'));
	{{end}}

	// 文本框自动伸缩
	$('.need-autogrow').autoGrow();

	{{if not .article.CloseReply}}
	loadComments();
	{{end}}

	// 文章链接，在本站的 iframe 中打开
	$('#wrapper .content').on('mousedown', 'a', function(evt){
		var url = $(this).attr('href');
		// $(this).attr('href', '/wr?u='+url);
		$(this).attr('href', url);
		$(this).attr('target', '_blank');
	});

	var len = '{{.article.Txt}}'.length;
	var readTime = Math.round(len / 900);
	if (readTime >= 1) {
		$('.read-time').text('预计阅读时间 '+readTime+' 分钟');
	} else {
		$('.read-time').text('预计阅读时间不到 1 分钟');
	}

	$('.weibo-btn').on('click', function(evt) {
		evt.preventDefault();

		window.open('http://service.weibo.com/share/share.php?url=http{{if .is_https}}s{{end}}://{{.setting.Domain}}/articles/{{.article.Id}}&title='+encodeURIComponent('{{.setting.Name}} - {{.article.Title}} by {{.article.AuthorTxt}} #golang#'), '_blank', 'width=550,height=370');
	});
});
</script>
{{include "cssjs/ckeditor.js.html" .}}

{{include "cssjs/prism.js.html" .}}

{{if .pos_ad.right1}}
	{{if eq .pos_ad.right1.AdType 1}}
		{{noescape .pos_ad.right1.Code}}
	{{end}}
{{end}}

{{if .pos_ad.right2}}
	{{if eq .pos_ad.right2.AdType 1}}
		{{noescape .pos_ad.right2.Code}}
	{{end}}
{{end}}

{{end}}
